<?php

session_start();
$docRoot =  $_SERVER['DOCUMENT_ROOT'];
$appName = '/gallerymodel/';
$baseUrl = $docRoot.$appName;
include_once $baseUrl.'action/constant.php';
include_once ACTIONBASE;

/**
 * Description of actionwrapper
 *
 * @author laimis
 */

class ObjectWrapper{

    public function wraperController(){
        $actionObject = $this->getRequestObject();
        if($actionObject != null){
            switch ($actionObject) {
                case 'user':
                    include_once BASEURL.'action/user/wrapper.php';
                    new UserWrapper();
                    break;
                case 'gallery':
                    include_once BASEURL.'action/gallery/wrapper.php';
                    new GalleryWrapper();
                    break;
                case 'photo':
                    include_once BASEURL.'action/photo/wrapper.php';
                    new PhotoWrapper();
                    break;
                case 'info':
                    include_once BASEURL.'action/info/wrapper.php';
                    new InfoWrapper();
                    break;
                default:
                    include_once BASEURL.'action/gallery/wrapper.php';
                    new GalleryWrapper();
                    break;
            }
        }else{
            include_once BASEURL.'web/error.php';
            exit ();
        }
    }

    public function getRequestObject(){
        $result = '';
        if(isset ($_GET['route'])){
            $strings = explode( '/',$_GET['route']);
            $result = $strings[0];
            $request['object'] = $strings[0];
            $request['action'] = $strings[1];
            $request['arg'] = $strings[2];
            $_REQUEST['request'] = $request;
        }
        return $result;
    }

    public function ObjectWrapper(){
        $this->wraperController();
    }
}
new ObjectWrapper();
?>
